from django.conf.urls import url
from rest_framework_jwt.views import obtain_jwt_token
from .views import statistical, users, specs, images, skus, spus, orders, permission, group
from rest_framework.routers import DefaultRouter

urlpatterns = [
    #  登录路由
    url(r'^authorizations/$', obtain_jwt_token),


    #-------数据统计---------
    # 用户总量统计
    url(r'^statistical/total_count/$', statistical.UserTotalCounterView.as_view()),
    #  日增用户统计
    url(r'^statistical/day_increment/$', statistical.UserDayCounterView.as_view()),
    #  日活跃用户统计
    url(r'^statistical/day_active/$', statistical.UserActiveCounterView.as_view()),
    #  日下单用户量统计
    url(r'^statistical/day_orders/$', statistical.UserOrderCounterView.as_view()),
    #  日分类商品访问量月增用户统计量
    url(r'^statistical/month_increment/$', statistical.UserMonthCounterView.as_view()),
    #  日分类商品访问量
    url(r'^statistical/goods_day_views/$', statistical.GoodsDayView.as_view()),

    #-------用户管理---------
    url(r'^users/$',users.UserView.as_view()),

    # -------规格路由表--------
    url(r'goods/simple/$',specs.SpecsView.as_view({'get':'simple'})),

    #-------获取sku的id--------
    url(r'skus/simple/$', images.ImageView.as_view({'get': 'simple'})),

    #-------获取三级分类信息--------
    url(r'skus/categories/$', skus.SKUCategorieView.as_view()),

    # -------获取spu表名称数据--------
    # url(r'goods/simple/$',skus.SPUSimpleView.as_view()),        #  此行代码和上面规格路由表的作用是一样的

    # -------获取spu商品规格信息--------
    url(r'goods/(?P<pk>\d+)/specs/$', skus.SPUSpecView.as_view()),

    #  获取品牌信息
    url(r'goods/brands/simple/$',spus.SPUSView.as_view({'get':'brand'})),
    #  获取一级分类
    url(r'goods/channel/categories/$',spus.SPUSView.as_view({'get':'channel'})),
    #  获取二级三级分类
    url(r'goods/channel/categories/(?P<pk>\d+)/$',spus.SPUSView.as_view({'get':'channels'})),
    #  上传图片
    url(r'goods/images/$', spus.SPUSView.as_view({'post':'image'})),
    #  保存spu数据
    # url(r'goods/$', spus.SPUGoodsView.as_view({'post': 'lsit'}))
    #  获取修改商品的详情信息
    url(r'goods/channel/categories/(?P<pk>\d+)/$', spus.SKUGoodsView.as_view({'get': 'list'})),

    #  获取权限类型列表数据
    url(r'permission/content_types/$', permission.PermissionView.as_view({'get':'content_types'})),

    #  保存分组表数据
    url(r'permission/simple/$', group.GroupView.as_view({'get':'simple'})),

]

#  规格表路由*****************************
router = DefaultRouter()
router.register('goods/specs',specs.SpecsView, base_name='specs')
print(router.urls)
urlpatterns += router.urls


#  图片查询路由****************************
router = DefaultRouter()
router.register('skus/images', images.ImageView, base_name='images')
urlpatterns += router.urls

#  sku表查询路由****************************
router = DefaultRouter()
router.register('skus', skus.SKUGoodsView, base_name='sku')
urlpatterns += router.urls

#  查询获取SPU表列表数据
router = DefaultRouter()
router.register('goods',spus.SPUGoodsView, base_name='goods')
# print(router.urls)
urlpatterns += router.urls

#  查询获取订单管理列表数据
router = DefaultRouter()
router.register('orders',orders.OrdersView, base_name='orders')
# print(router.urls)
urlpatterns += router.urls

#  用户权限管理
router = DefaultRouter()
router.register('permission/perms',permission.PermissionView, base_name='perms')
# print(router.urls)
urlpatterns += router.urls

#  分组表管理
router = DefaultRouter()
router.register('permission/groups',group.GroupView, base_name='groups')
print(router.urls)
urlpatterns += router.urls
